@extends('backend.layouts.app')

@section('title', $title = '游戏列表')

@section('breadcrumb')
    <a href="">系统设置</a>
    <a href="">集成系统</a>
    <a href="">{{$title}}</a>
@endsection

@section('content')
    <div class="layui-main">
        <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
            <legend>{{$title}}</legend>
        </fieldset>

        <form class="layui-form layui-form-pane" method="GET"
              action="{{ route('game_list.index') }}">
            {{ csrf_field() }}
            <div class="layui-form-item" id="toolbarDemo">
                <div class=" layui-inline">
                    <label class="layui-form-label">平台编号</label>
                    <div class="layui-input-block">
                        <select name="main_game_plat_code" lay-verify="" lay-search="">
                            <option value="">请选择平台编号</option>
                            @foreach($plats as $plat)
                                <option value={{$plat->main_game_plat_code}} @if($params['main_game_plat_code']===$plat->main_game_plat_code) selected @endif>{{$plat->main_game_plat_name}}</option>
                            @endforeach
                        </select>
                    </div>
                </div>
                <div class=" layui-inline">
                    <label class="layui-form-label">游戏名称</label>
                    <div class="layui-input-block">
                        <input type="text" name="cn_name" width="300" autocomplete="off"
                               placeholder="请输入游戏名称"
                               class="layui-input"
                               value="{{old('cn_name',$params['cn_name'])}}">
                    </div>
                </div>

                <div class="layui-inline">
                    <label class="layui-form-label">状态</label>
                    <div class="layui-input-inline">
                        <select name="status" lay-verify="" lay-search="">
                            <option value="">直接选择或搜索选择</option>
                            <option value="0" @if($params['status']===0) selected @endif>关闭</option>
                            <option value="1" @if($params['status']===1) selected @endif>启用</option>
                            <option value="2" @if($params['status']===2) selected @endif>维护</option>
                        </select>
                    </div>
                </div>
                <button class=" layui-btn" lay-submit="" lay-filter="demo1">提交</button>
            </div>

        </form>
        <div class="layui-btn-group demoTable">
            <a href="{{ route('game_list.create') }}" class="layui-btn">添加</a>
            <button class="layui-btn  layui-btn-danger" data-type="getCheckData"><i class="layui-icon"></i> 删除</button>
        </div>

        <div class="layui-form">
            @if($gameLists->count())
                <table class="layui-table" lay-filter="table"
                       lay-data="{id:'DeleteTable',totalRow: true,limit:{{$limit+1}},toolbar: 'default',defaultToolbar:['exports', 'print']}">
                    <thead>
                    <tr>
                        <th lay-data="{type:'checkbox', fixed: 'left'}">#</th>
                        <th lay-data="{field:'id', width:50, sort: true}">id</th>
                        <th lay-data="{field:'unique_key',  width:100, sort: true}">唯一编号</th>
                        <th lay-data="{field:'main_game_plat_code',  width:100, sort: true}">游戏平台</th>
                        <th lay-data="{field:'cn_name', width:150,  sort: true}">中文名</th>
                        <th lay-data="{field:'en_name',width:150,  sort: true}">英文名</th>
                        <th lay-data="{field:'pc_game_code', width:150,  sort: true}">编号</th>
                        <th lay-data="{field:'pc_game_deputy_code',width:150,  sort: true}">编号扩展</th>
                        <th lay-data="{field:'mobile_game_code',  width:150, sort: true}">移动端编号</th>
                        <th lay-data="{field:'mobile_game_deputy_code',width:150,  sort: true}">移动端编号扩展</th>
                        <th lay-data="{field:'record_match_code',  width:150, sort: true}">匹配编号</th>
                        <th lay-data="{field:'record_match_deputy_code',width:150,  sort: true}">匹配编号扩展</th>
                        <th lay-data="{field:'img1',width:150}">图片1</th>
                        <th lay-data="{field:'img2',width:150,  sort: true, }">图片2</th>
                        <th lay-data="{field:'type',width:100,  sort: true}">游戏类型</th>
                        <th lay-data="{field:'category', width:100, sort: true}">游戏分类</th>
                        <th lay-data="{field:'line_num', width:80, sort: true}">线数</th>
                        <th lay-data="{field:'money_return_rate', width:80, sort: true}">返奖率</th>
                        <th lay-data="{field:'bonus_pool', width:80, sort: true}">奖金池</th>
                        <th lay-data="{field:'able_demo', width:80, sort: true}">试玩</th>
                        <th lay-data="{field:'able_recommend', width:80, sort: true}">推荐</th>
                        <th lay-data="{field:'is_lobby', width:80, sort: true}">大厅</th>
                        <th lay-data="{field:'status', width:80, sort: true}">状态</th>
                        <th lay-data="{field:'updated_at', width:170, sort: true}">修改时间</th>
                        <th lay-data="{field:'created_at', width:170, sort: true}">创建时间</th>
                        <th lay-data="{field:'cz', width:170, sort: true}">操作</th>
                    </tr>
                    </thead>
                    <tbody>
                    @foreach($gameLists as $index => $gameList)
                        <tr>
                            <td></td>
                            <td>{{ $gameList->id }}</td>
                            <td>{{ $gameList->unique_key }}</td>
                            <td>{{ $gameList->main_game_plat_code  }}</td>
                            <td>{{ $gameList->cn_name  }}</td>
                            <td>{{ $gameList->en_name  }}</td>
                            <td>{{ $gameList->pc_game_code  }}</td>
                            <td>{{ $gameList->pc_game_deputy_code  }}</td>
                            <td>{{ $gameList->mobile_game_code  }}</td>
                            <td>{{ $gameList->mobile_game_deputy_code  }}</td>
                            <td>{{ $gameList->record_match_code  }}</td>
                            <td>{{ $gameList->record_match_deputy_code  }}</td>
                            <td>@if(!empty($gameList->getImg1Url()))<img src="{{$gameList->getImg1Url()}}">@endif
                            </td>
                            <td>@if(!empty($gameList->getImg2Url()))<img src="{{ $gameList->getImg2Url()}}">@endif</td>
                            <td>{{ $gameList->gameType->name??''  }}</td>
                            <td>{{ $gameList->gameCategory->name ??'' }}</td>
                            <td>{{ $gameList->gameLine->name??''  }}</td>
                            <td>{{ $gameList->money_return_rate  }}</td>
                            <td>{{ $gameList->bonus_pool  }}</td>
                            <td>{{ $gameList->able_demo?'是':'否'  }}</td>
                            <td>{{ $gameList->able_recommend ?'是':'否' }}</td>
                            <td>{{ $gameList->is_lobby?'是':'否'  }}</td>
                            <td>{{ $gameList->getStatus()  }}</td>
                            <td>{{ $gameList->updated_at  }}</td>
                            <td>{{ $gameList->created_at  }}</td>

                            <td>
                                <a href="{{ route('game_list.edit', $gameList->id) }}"
                                   class="layui-btn layui-btn-sm layui-btn-normal">编辑</a>
                                <a href="javascript:;" class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
                            </td>
                        </tr>
                    @endforeach

                    </tbody>
                </table>
                <div id="paginate-render"></div>
            @else
                <br/>
                <blockquote class="layui-elem-quote">暂无数据!</blockquote>
            @endif

        </div>
    </div>

@endsection

@section('scripts')
    @include('backend.layouts._paginate',[ 'count' => $gameLists->total(), 'delBatchUrl'=>route('game_list.destroy'),'limit'=>$limit])
    <script>
        layui.use('laydate', function () {
            var laydate = layui.laydate;

            //日期时间选择器
            laydate.render({
                elem: '#created_at_start'
                , type: 'datetime'
            });

            laydate.render({
                elem: '#created_at_end'
                , type: 'datetime'
            });
        });
    </script>
@endsection
